package com.itheima.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

@Component
public class JdbcConfig {
   @Value("${jbdc.driver}")
   private String driverClassName;
   @Value("${jdbc.url}")
    private String url;
   @Value("${jdbc.username}")
    private String username;
   @Value("${jdbc.password}")
    private String password;
   @Bean
    public DataSource dataSource(){
       DruidDataSource dataSource=new DruidDataSource();
       dataSource.setDriverClassName("com.mysql.jbdc.Driver");
       dataSource.setUrl("jdbc:mysql://loaclhost:3306/db1");
       dataSource.setUsername("root");
       dataSource.setPassword("root");
       return dataSource;
   }
}
